import { requestAuth } from '../service'
import Cookies from 'js-cookie'
export const checkAuthToken = (props) => {
  const cookie_val = Cookies.get('znyToken')
  const localStorage_val = window.localStorage.getItem('znyToken')
  const pathname = "http://localhost:8000/" + props.history.location.pathname;
  if (cookie_val === undefined) {
    if (localStorage_val === null) {
      UI.error("获取Token失败")
      setTimeout(() => {
        //window.open("http://portal.cs.msdi.cn/r1/SignOnServlet?FromUrl=" + pathname, '_parent');
      }, 1000);
    } else {
      requestAuth(localStorage_val)
        .then(res => {
          console.log(res)
        })
    }
  } else {
    requestAuth(cookie_val)
      .then(res => {
        console.log(res)
      })
  }
} 